<template>
  <a-row :gutter="24">
    <a-col :span="12">
      <a-table
        ref="table"
        rowKey="id"
        size="middle"
        bordered
        :columns="columns"
        :dataSource="dataSource">
      </a-table>
    </a-col>
    <a-col :span="12">
      <a-textarea v-model="content" placeholder="请输入年份" style="height: 350px" />
    </a-col>
  </a-row>
</template>

<script>
import EpaWeekly from "../../../../myService/EpaWeekly";
import moment from 'moment'

export default {
  name: "Step2",
  data(){
    return{
      content:"",
      dataSource:[],
      columns: [
        {
          title:'分类名称',
          align:"center",
          dataIndex: 'name'
        },
        {
          title:'数量',
          align:"center",
          dataIndex: 'num'
        },
        {
          title:'占比',
          align:"center",
          dataIndex: 'percentage'
        },
      ],
      model:{}
    }
  },
  created() {

  },
  methods:{
    moment,
    loading(model){
      console.log(model)
      let startTime=model.startTime;
      let endTime=model.endTime;
      let top=model.top;
      this.model=model
      console.log(this.model)
      let date=sessionStorage.getItem('date');
      EpaWeekly.getCategory({top:top,date:date}).then((res)=>{
        this.dataSource=res.result.list
        console.log(this.dataSource)
        let sum=res.result.sum;
        console.log(sum)
        let start=moment(startTime).format("M月D日")
        let end=moment(endTime).format("M月D日")
        this.content=start+"至"+end+",我市共受理生态环境类信访件"+sum+"件。其中,";
        console.log(this.dataSource)
        for(var i=0;i<this.dataSource.length-1;i++){
          this.content=this.content+this.dataSource[i].name+this.dataSource[i].num+"件，占"+this.dataSource[i].percentage+"%;";
        }
        this.content=this.content+this.dataSource[this.dataSource.length-1].name+this.dataSource[this.dataSource.length-1].num+"件，占"+this.dataSource[this.dataSource.length-1].percentage+"%。";
        this.model.summary=this.content;
      })
    },
    updata(){
      console.log(this.model)
      EpaWeekly.updataEpaWeekly(this.model).then((res)=>{
        console.log(res)
      })
    }
  }
}
</script>

<style scoped>

</style>